{template 'common/header'}
<link rel="stylesheet" href="../addons/wwr_bbs/app/resource/components/dropload/dropload.css">
<div class="mui-content">
    <div id="slider" class="mui-slider">
        <div class="mui-slider-group">
            <div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
                <div class="mui-scroll-wrapper-ext">
                    <div class="mui-scroll-ext">
                        <div class="list-content">

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="page" style="display:none"></div>
<script type="text/javascript" src="../addons/wwr_bbs/app/resource/components/dropload/dropload.min.js"></script>
<script>
    //初始化滚动区域
    $('.mui-content').css('overflow','hidden');
    $('.mui-slider-group').height($(window).height() + $(window).scrollTop());
    //nav激活
    mui.init();
    mui('.mui-bar-tab').on('tap', 'a',
        function() {
            var $this = $(this);
            if (this.getAttribute('href') != null) {
                console.log(this.getAttribute('href'));
                location.href = this.getAttribute('href');
            } else {
                return false;
            }
        })



    //上拉加载活动列表
    var loadItem=function(id,status){
        var counter = 0;
        // 每页展示4个
        var num = 10;
        var pageStart = 0,pageEnd = 0,thispage = 1,thispages = 50;
        // dropload
        $(id).find('.mui-scroll-ext').dropload({
            scrollArea : $(id).find('.mui-scroll-wrapper-ext'),
            loadDownFn : function(me){
                $.ajax({
                    type: 'GET',
                    url: "{php echo $this->createMobileUrl('canyu')}&page="+thispage+"&psize="+thispages+"&ajax=1&status="+status,
                    dataType: 'json',
                    success: function(data){
                        console.log(data);
                        //alert(type);
                        var result = '', joinstime = '', joinetime = '', starttime = '', endtime = '', stime = new Date();
                        counter++;
                        pageEnd = num * counter;
                        pageStart = pageEnd - num;
                        result+= '<ul class="mui-table-view">'
                        for(var i = pageStart; i < pageEnd; i++){
                            if (data.tpage == 0){
                                result = '<div class="no-orders-at-all">'
                                    +'<div class="head-block">'
                                    +'    <div class="blank-icon mui-ext-icon mui-icon-mhuodong"></div>'
                                    +'    <p class="hint"></p>'
                                    +'    <p class="recommend-hint"></p>'
                                    +'</div></div>';
                                // 锁定
                                me.lock();
                                // 无数据
                                me.noData();
                                break;
                            }
                            result+=' <li class="mui-table-view-cell"><a href="{php echo $this->createMobileUrl('detail')}&id='+data.lists[i].pid+'">'+data.lists[i].content+'</a></li>'
                            if((i + 1) >= data.lists.length && thispage == data.tpage){
                                // 锁定
                                me.lock();
                                // 无数据
                                me.noData();
                                break;
                            }else if((i + 1) >= data.lists.length) {
                                thispage++;
                                counter = 0;
                                pageEnd = 0;
                                pageStart =0;
                            }
                        }
                        result+='    </ul>';

                        $(id).find('.list-content').append(result);
                        // 每次数据加载完，必须重置
                        me.resetload();

                    },
                    error: function(xhr, type){
                        // alert('加载失败，请刷新下重试!');
                        // 即使加载出错，也得重置
                        me.resetload();
                    }
                });
            }
        });
    }
    loadItem('#item1mobile',$('.mui-control-item.mui-active').attr("data"));

</script>
</body>
</html>